package com.wlz.ota.util;

import com.wlz.ota.entity.ImportPackageController;
import com.wlz.ota.entity.PartTypeEntity;

import javax.validation.constraints.Null;
import java.util.List;

/**
 * @author wlz
 * @date 2022-10-31  7:04 下午
 */
public class PartTypeUtils {


    private static List<ImportPackageController> packageControllers;

    static {
        packageControllers = ExcelImportUtil.importExcel("/Users/wlz/Downloads/ARCFOX-_S795b1661-609c-40d9-b950-b917dd951bf6.xlsx",
                ImportPackageController.class, "/packageController");
    }

  public static PartTypeEntity getPartType(String partName) {
      for (ImportPackageController packageController : packageControllers) {
          if (partName.equalsIgnoreCase(packageController.getPartName())) {
              PartTypeEntity partTypeEntity = new PartTypeEntity();
              partTypeEntity.setPartTypeName(partName);
              if ("否".equalsIgnoreCase(packageController.getIsCalibration())) {
                  partTypeEntity.setIsCalibration(0);
              }else {
                  partTypeEntity.setIsCalibration(1);
              }
              return partTypeEntity;
          }
      }
      return null;
  }

    public static void main(String[] args) {
        PartTypeEntity pas = getPartType("PAS");
        System.out.println(pas);
    }

}
